package com.baseweb.webadmin.weixin.pay;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.baseweb.webadmin.weixin.sign.ConfingJsSign;

@Controller
@RequestMapping(value="/test/webpage/weixin/pay")
public class WebPagePay {
	private static Logger  logeer=LoggerFactory.getLogger(WebPagePay.class);
	/**
	 * 微信支付，去支付
	 * @return 
	 */
	@RequestMapping(value="/toPay")
	public ModelAndView  toPay(HttpServletRequest request,OrderData orderData){
		logeer.info("微信支付开始调用");
		ModelAndView modelAndView = new ModelAndView("weixin/jsp/order/confirmPay");
		try {
			request.setCharacterEncoding("utf-8"); 
			logeer.info("PayInterface start");
            //获取configjs签名
			Map<String, String> confingJsSign = ConfingJsSign.getConfingJsSign(request);
			modelAndView.addObject("confingJsSign",confingJsSign);
			//获取微信支付签名
			PayInterfaceData payInterfaceData = new PayInterfaceData();
			Map params =  payInterfaceData.getPaySignaData(request,orderData);
			modelAndView.addObject("params", params);
			modelAndView.addObject("orderData", orderData);
		} catch (Exception e) {
			logeer.error("微信支付时出现问题",e);
		}
		return modelAndView;
	}
}
